﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class AuditingRecord : IAccessible<T_AuditingRecord, AuditingRecord>, ILogicEntity<T_AuditingRecord, AuditingRecord>
    {
        #region Fileds
        public int Id { get; set; }

        public int MeetingId { get; set; }
        public int JournalId { get; set; }

        /// <summary>
        /// 任务分发者
        /// </summary>
        public string Distributor { get; set; }

        public int ManuscriptId { get; set; }

        /// <summary>
        /// 专家用户名
        /// </summary>
        public string UserName { get; set; }

        public ExamineStep Step { get; set; }
        /// <summary>
        /// 专审状态
        /// </summary>
        public ExamineStatus ExamineStatus { get; set; }

        public string Message { get; set; }

        /// <summary>
        /// 创建记录时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 上一次操作记录时间
        /// </summary>
        public DateTime LastRecord { get; set; }
        /// <summary>
        /// 审稿单id
        /// </summary>
        public int AppendixId { get; set; }
        
        /// <summary>
        /// 稿件类型 审稿单项
        /// </summary>
        public string ManuscriptType { get; set; }

        /// <summary>
        /// 原创性
        /// </summary>
        public string Originality { get; set; }

        /// <summary>
        /// 实用性
        /// </summary>
        public string Usefulness { get; set; }

        /// <summary>
        /// 技术合理性
        /// </summary>
        public string Soundness { get; set; }

        /// <summary>
        /// 语言描述
        /// </summary>
        public string LinguisticQuality { get; set; }

        /// <summary>
        /// 稿件解决了什么问题
        /// </summary>
        public string Resolution { get; set; }

        /// <summary>
        /// 主要领域作出的贡献
        /// </summary>
        public string Contribution { get; set; }

        /// <summary>
        /// 在哪些方面确实缺乏原创
        /// </summary>
        public string Originalless { get; set; }
        /// <summary>
        /// 审核意见类型
        /// 0：推荐接收
        /// 1：接收
        /// 2：需较小修订
        /// 3：需较大修订
        /// 9：拒绝
        /// </summary>
        public ExamineSuggest SuggestStatus { get; set; }
        /// <summary>
        /// 审核意见
        /// </summary>
        public string Suggestion { get; set; }
        #endregion

        /// <summary>
        /// 审稿专家
        /// </summary>
        public Expert Expert { get; set; }

        /// <summary>
        /// 要求审稿完成时间
        /// </summary>
        public DateTime ExamineFinishDate { get; set; }

        /// <summary>
        /// 用户真实姓名
        /// </summary>
        public string ExpertRealName { get; set; }

       

        protected override void Covariant(T_AuditingRecord model)
        {
            if (model != null)
            {
                this.AppendixId = model.AppendixId;
                this.CreateTime = model.CreateTime;
                this.Distributor = model.Distributor;
                this.ExamineStatus = (Enum.ExamineStatus)model.ExamineStatus;
                this.Id = model.Id;
                this.JournalId = model.JournalId;
                this.LastRecord = model.LastRecord;
                this.ManuscriptId = model.ManuscriptId;
                this.Message = model.Message;
                this.UserName = model.UserName;
                this.Step = (ExamineStep)model.Step;
                this.ExamineFinishDate = model.ExamineFinishDate;
                this.SuggestStatus = (ExamineSuggest)model.SuggestStatus;
                this.Suggestion = model.Suggestion;
                this.Contribution = model.Contribution;
                this.LinguisticQuality = model.LinguisticQuality;
                this.ManuscriptType = model.ManuscriptType;
                this.MeetingId = model.MeetingId;
                this.Originality = model.Originality;
                this.Originalless = model.Originalless;
                this.Resolution = model.Resolution;
                this.Soundness = model.Soundness;
                this.Usefulness = model.Usefulness;
            }
        }

        protected override T_AuditingRecord Inverter(AuditingRecord model)
        {
            if (model != null)
            {
                return new T_AuditingRecord()
                {
                    AppendixId = model.AppendixId,
                    CreateTime = model.CreateTime,
                    Distributor = model.Distributor,
                    ExamineStatus = (int)model.ExamineStatus,
                    Id = model.Id,
                    JournalId = model.JournalId,
                    LastRecord = model.LastRecord,
                    ManuscriptId = model.ManuscriptId,
                    Message = model.Message,
                    MeetingId=model.MeetingId,
                    UserName = model.UserName,
                    Step = (int)model.Step,
                    ExamineFinishDate=model.ExamineFinishDate,
                    Suggestion=model.Suggestion,
                    SuggestStatus=(int)model.SuggestStatus,
                    Contribution=model.Contribution,
                    LinguisticQuality=model.LinguisticQuality,
                    ManuscriptType=model.ManuscriptType,
                    Originality=model.Originality,
                    Originalless=model.Originalless,
                    Resolution=model.Resolution,
                    Soundness=model.Soundness,
                    Usefulness=model.Usefulness
                };
            }
            return null;
        }

        public AuditingRecord Set(T_AuditingRecord dbModel)
        {
            Covariant(dbModel);
            return this;
        }

        public AuditingRecord LoadExpert(Expert expert)
        {
            this.Expert = expert;
            return this;
        }
    }
}
